#coding=utf-8

from stockdb.misc import *

n = 20

held = False
money = 10000.0
ds = 0

n2 = 0

tds = find_stock('600036').tds
tds.reverse()
print tds[0],len(tds)

for td in tds[n:]:

    c = td.price.fq('close')
    pre_td = td.pre
    
    if not held:
        top = pre_td.top(n, fq=True)
        if c > top:
            ds = money/c
            held = True
            print '买进: %s. 点位:%.2f'%(td, c)
            
    else:
        lowest = pre_td.lowest(10, fq=True)
        if (not lowest) or (c >= lowest):pass
        else:
            money = ds * c
            held = False
            
            print '卖出: %s. 点位:%.2f;money:%.1f\n'%(td, c, money)
            #print '\t 大盘:%.1f; 资金:%.1f'%(c/100.0, money/10000.0)  
            #print '\t %.1f'%((money/10000.0)/(c/100.0))
            
            n2 = n +1
            
print n2
